home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / powervww / pvhgr_.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-05  |  7.6 KB  |  186 lines

  1. ;   ____________________________________________________
  2. ;  |                                                    |
  3. ;  |  Project:     POWER VIEW INTERFACE                 |
  4. ;  |  File:        PVHGR_.ASM                           |
  5. ;  |  Compiler:    32-bit Turbo Assembler               |
  6. ;  |                                                    |
  7. ;  |  Subject:     Fast line drawing function           |
  8. ;  |                                                    |
  9. ;  |  Author:      Emil Dotchevski                      |
  10. ;  |____________________________________________________|
  11. ;  E-mail: zajo@geocities.com
  12. ;  URL:    http://www.geocities.com/SiliconValley/Bay/3577
  13.  
  14.                 .386p
  15.                 model   flat
  16.  
  17.                 .code
  18.                 public  draw_line_bin_
  19.  
  20. ;---------------------------------------------------------------------------
  21. ; Description:
  22. ;   draws a line
  23. ; Entry:
  24. ;   edi - x1
  25. ;   esi - y1
  26. ;   ebx - x2
  27. ;   eax - y2
  28. ;   edx - plane 0 address, plane4 address==mul_table
  29. ;   cl  - ....xxxx color
  30. ;   ecx - planes step (rest of ecx)
  31. ;   ebp - xl
  32. ; Exit:
  33. ;   none
  34. ; Destroys:
  35. ;   all
  36. ;---------------------------------------------------------------------------
  37. mul_table       dd      ?
  38. draw_line_bin_: mov     word ptr nr_fix0,08408h ; or  p0[esi+ecx],al
  39.                 mov     word ptr nr_fix1,08408h ; or  p1[esi+ecx],al
  40.                 mov     word ptr nr_fix2,08408h ; or  p2[esi+ecx],al
  41.                 mov     word ptr nr_fix3,08408h ; or  p3[esi+ecx],al
  42.                 mov     word ptr nc_fix0,08408h ; or  p0[esi+ecx],al
  43.                 mov     word ptr nc_fix1,08408h ; or  p1[esi+ecx],al
  44.                 mov     word ptr nc_fix2,08408h ; or  p2[esi+ecx],al
  45.                 mov     word ptr nc_fix3,08408h ; or  p3[esi+ecx],al
  46.                 shr     ecx,1
  47.                 jc      dl_0010
  48.                 mov     word ptr nr_fix0,0A420h ; and p0[esi+ecx],ah
  49.                 mov     word ptr nc_fix0,0A420h ; and p0[esi+ecx],ah
  50. dl_0010:        shr     ecx,1
  51.                 jc      dl_0020
  52.                 mov     word ptr nr_fix1,0A420h ; and p1[esi+ecx],ah
  53.                 mov     word ptr nc_fix1,0A420h ; and p1[esi+ecx],ah
  54. dl_0020:        shr     ecx,1
  55.                 jc      dl_0030
  56.                 mov     word ptr nr_fix2,0A420h ; and p2[esi+ecx],ah
  57.                 mov     word ptr nc_fix2,0A420h ; and p2[esi+ecx],ah
  58. dl_0030:        shr     ecx,1
  59.                 jc      dl_0040
  60.                 mov     word ptr nr_fix3,0A420h ; and p3[esi+ecx],ah
  61.                 mov     word ptr nc_fix3,0A420h ; and p3[esi+ecx],ah
  62. dl_0040:        mov     dword ptr nr_fix0+3,edx ; or/and edx[esi+ecx],al/ah
  63.                 mov     dword ptr nc_fix0+3,edx ; (set up planes offsets)
  64.                 add     edx,ecx
  65.                 mov     dword ptr nr_fix1+3,edx
  66.                 mov     dword ptr nc_fix1+3,edx
  67.                 add     edx,ecx
  68.                 mov     dword ptr nr_fix2+3,edx
  69.                 mov     dword ptr nc_fix2+3,edx
  70.                 add     edx,ecx
  71.                 mov     dword ptr nr_fix3+3,edx
  72.                 mov     dword ptr nc_fix3+3,edx
  73.                 add     edx,ecx
  74.                 mov     mul_table,edx
  75.                 sub     ebx,edi                 ; delta x (signed)
  76.                 mov     ecx,ebx
  77.                 mov     byte ptr nc_fix4+1,0CCh ; ror ah,1
  78.                 mov     byte ptr nc_fix5+1,0C8h ; ror al,1
  79.                 mov     byte ptr nc_fix6+1,0D1h ; adc ecx,0
  80.                 jge     dl_0050
  81.                 mov     byte ptr nc_fix4+1,0C4h ; rol ah,1
  82.                 mov     byte ptr nc_fix5+1,0C0h ; rol al,1
  83.                 mov     byte ptr nc_fix6+1,0D9h ; sbb ecx,0
  84.                 neg     ecx                     ; delta x (unsigned)
  85. dl_0050:        sub     eax,esi                 ; delta y (signed)
  86.                 mov     edx,eax
  87.                 jge     dl_0060
  88.                 neg     edx                     ; delta y (unsigned)
  89.                 neg     ebp                     ; xl (signed)
  90. dl_0060:        cmp     ecx,edx
  91.                 jae     dl_draw_hor             ; optimize line loop
  92.  
  93. dl_draw_ver:    mov     eax,ebx                 ; delta x (signed)
  94.                 mov     ebx,edx                 ; delta y (unsigned) (ok)
  95.                 sal     eax,16                  ; 16.16 delta x (signed)
  96.                 cdq                             ; 48.16 delta x (signed)
  97.                 idiv    ebx                     ; 16.16 x step (signed)
  98.                 xchg    eax,esi
  99.                 imul    ebp
  100.                 mov     edx,esi                 ; (ok)
  101.                 or      eax,eax
  102.                 jns     dldv_0010
  103.                 neg     eax
  104. dldv_0010:      mov     esi,eax                 ; (ok)
  105.                 sal     edi,16                  ; (ok)
  106.                 add     edi,8000h               ; 1/2
  107.                 or      ebx,ebx
  108.                 jz      dl_done
  109. ;---------------------------------------------------------------------------
  110. ; esi     - start row base
  111. ; edi     - 16.16 start column
  112. ; edx     - 16.16 column step
  113. ; ebp     - xl/-xl
  114. ; ebx     - delta_y (unsigned)
  115. ; nr_fix0 - or/and plane0[esi+edi],al/ah
  116. ; nr_fix1 - or/and plane1[esi+edi],al/ah
  117. ; nr_fix2 - or/and plane2[esi+edi],al/ah
  118. ; nr_fix3 - or/and plane3[esi+edi],al/ah
  119. ;---------------------------------------------------------------------------
  120. next_row:       xor     ecx,ecx
  121.                 shld    ecx,edi,16
  122.                 add     edi,edx
  123.                 mov     al,80h
  124.                 ror     al,cl
  125.                 shr     ecx,3
  126.                 mov     ah,al
  127.                 not     ah
  128. nr_fix0:        or      1111h[esi+ecx],al
  129. nr_fix1:        or      2222h[esi+ecx],al
  130. nr_fix2:        or      3333h[esi+ecx],al
  131. nr_fix3:        or      4444h[esi+ecx],al
  132.                 add     esi,ebp
  133.                 dec     ebx
  134.                 jnz     next_row
  135.                 jmp     dl_done
  136.  
  137. dl_draw_hor:    sal     eax,16                  ; 16.16 delta y (signed)
  138.                 jecxz   dldh_0010
  139.                 cdq                             ; 48.16 delta_y (signed)
  140.                 idiv    ecx                     ; 16.16 y step (signed)
  141. dldh_0010:      mov     edx,eax
  142.                 mov     ebx,esi
  143.                 sal     ebx,16                  ; (ok)
  144.                 add     ebx,8000h               ; 1/2
  145.                 mov     ebp,mul_table
  146.                 xchg    ecx,edi
  147.                 mov     al,80h
  148.                 ror     al,cl
  149.                 mov     ah,al
  150.                 not     ah
  151.                 shr     ecx,3
  152.                 or      edi,edi
  153.                 jz      dl_done
  154. ;---------------------------------------------------------------------------
  155. ; ebx     - 16.16 start row
  156. ; edx     - 16.16 row step
  157. ; ecx     - start column
  158. ; edi     - delta_x (unsigned)
  159. ; ebp     - mul table
  160. ; nc_fix0 - or/and plane0[esi+ecx],al/ah
  161. ; nc_fix1 - or/and plane1[esi+ecx],al/ah
  162. ; nc_fix2 - or/and plane2[esi+ecx],al/ah
  163. ; nc_fix3 - or/and plane3[esi+ecx],al/ah
  164. ; nc_fix4 - ror/rol ah,1
  165. ; nc_fix5 - ror/rol al,1
  166. ; nc_fix6 - adc/sbb edi,0
  167. ;---------------------------------------------------------------------------
  168. next_col:       xor     esi,esi
  169.                 shld    esi,ebx,16
  170.                 add     ebx,edx
  171.                 mov     esi,[ebp+esi*4]
  172. nc_fix0:        or      1111h[esi+ecx],al
  173. nc_fix1:        or      2222h[esi+ecx],al
  174. nc_fix2:        or      3333h[esi+ecx],al
  175. nc_fix3:        or      4444h[esi+ecx],al
  176. nc_fix4:        ror     ah,1
  177. nc_fix5:        ror     al,1
  178. nc_fix6:        adc     ecx,0
  179.                 dec     edi
  180.                 jnz     next_col
  181.  
  182. dl_done:        ret
  183.  
  184.                 end
  185.